package com.newblog2_0.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.newblog2_0.model.ArticleInfo;
import com.newblog2_0.model.vo.ArticleInfoVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * Created with Intellij IDEA.
 * Description;
 * User:TQ02
 * Data:2023-12-16
 * Time:15:10
 * Text：
 */
@Mapper
public interface ArticleMapper extends BaseMapper<ArticleInfo> {

//    查询所有的文章
@Select("select * from articleinfo order by aId desc limit #{paszie} offset #{ofset}")  //offest下标，pasize数目
List<ArticleInfoVo> getListByPage(@Param("paszie")Integer pasize , @Param("ofset")Integer ofest);

//查询文章数目
    @Select("select count(*) from articleinfo")
    int getCount();

//    查询指定文章
    @Select("select * from articleinfo where aId=#{aId}")
    ArticleInfo getId(@Param("aId")int aId);

//   查询指定用户有多少文章
    @Select("select count(*) from articleinfo where uId=#{uId}")
    int getArtCount(int uId);
//    自增
    @Update("update articleinfo set rcount=rcount+1 where aId=#{aId}")
    int getinsert(int aId);

}
